﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HCFramework.API.LINQ;
using System.Data;
using Telerik.Web.UI;
using System.IO;

namespace HCFramework.FeedBack
{
    public partial class FeedBackManagement : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }
        protected void RadGridMain_PreRender(object sender, EventArgs e)
        {
            LoadGridData();
        }
        public void LoadGridData()
        {
            HCDataContext db = new HCDataContext();
            var result = from a in db.FeedBacks
                         orderby a.InsertDate descending
                         select a;
            DataTable dt = M.Common.LINQToDataTable(result);
            RadGridMain.DataSource = dt;
            RadGridMain.DataBind();
        }
        protected void RadGridMain_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            //if (e.CommandName == "Reply")
            //{
            //    GridDataItem dataItem = (GridDataItem)e.Item;
            //    Guid id = Guid.Parse(dataItem["FeedBackID"].Text);
            //    lblID.Text = id.ToString();
            //    PanelGrid.Visible = false;
            //    PanelReply.Visible = true;
            //    BindReply(id);
            //}
        }

        protected void LinkButtonDelete_Click(object sender, EventArgs e)
        {
            foreach (GridItem gridItem in RadGridMain.SelectedItems)
            {
                GridDataItem dataItem = (GridDataItem)gridItem;
                int id = int.Parse(dataItem["FeedBackID"].Text);

                C.FeedBackController.Delete(id);
            }
        }
    }
}